import java.util.ArrayList;
import java.util.List;

/**
 * @author wcj
 * @Date 2021/6/1 12:49
 * @Version 1.0
 */
public class HeapOOM {

    static class OOMObject {
    }

    /**
     * 堆内存OOM：堆内存放实例对象，只要我们不停的创建对象，且让其跟GCROOT节点引用不断就会发生
     * -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError
     *
     * @param args
     */
    public static void main(String[] args) {
        List<OOMObject> oomObjects = new ArrayList<>();
        for (; ; ) {
            oomObjects.add(new OOMObject());
        }
    }
}
